
       PROGRAM-ID. DRIVER.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS A-CLASS AS "AClass"
           .
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-OBJECT-1  OBJECT REFERENCE A-CLASS.
       01  WS-OBJECT-2  OBJECT REFERENCE A-CLASS.
       PROCEDURE DIVISION.
            DISPLAY " "
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY " "

            DISPLAY "Creating instance 1...."
            SET WS-OBJECT-1 TO A-CLASS:>new
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY "Count per instance 1: " WS-OBJECT-1:>getCount 
            DISPLAY "ID of instance 1:     " WS-OBJECT-1:>getID
            DISPLAY " "

            DISPLAY "Creating instance 2...."
            SET WS-OBJECT-2 TO A-CLASS:>new
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY "Count per instance 1: " WS-OBJECT-1:>getCount 
            DISPLAY "Count per instance 2: " WS-OBJECT-2:>getCount 
            DISPLAY "ID of instance 1:     " WS-OBJECT-1:>getID
            DISPLAY "ID of instance 2:     " WS-OBJECT-2:>getID
            DISPLAY " "

            DISPLAY "Disposing of instance 1...."
            INVOKE WS-OBJECT-1 "dispose"
            SET    WS-OBJECT-1 TO NULL
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY " "

            DISPLAY "Disposing of instance 2...."
            INVOKE WS-OBJECT-2 "dispose"
            SET    WS-OBJECT-2 TO NULL
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY " "

            DISPLAY "Creating a new object for instance 1...."
            SET WS-OBJECT-1 TO A-CLASS:>new
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY "Count per instance 1: " WS-OBJECT-1:>getCount 
            DISPLAY "ID of instance 1:     " WS-OBJECT-1:>getID
            DISPLAY " "

            DISPLAY "Disposing of instance 1 again...."
            INVOKE WS-OBJECT-1 "dispose"
            SET    WS-OBJECT-1 TO NULL
            DISPLAY "Count per the class:  " A-CLASS:>getCount
            DISPLAY " "

            GOBACK.
